package com.example.app.aspect;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Service;

import java.util.Arrays;

@Aspect
@Service
public class DataAspect {

//    @Around("execution(* com.example.app.service.impl.*.*(..))")
    public Object execute(ProceedingJoinPoint joinPoint){
        String name = joinPoint.getSignature().getName();
        String args = Arrays.toString(joinPoint.getArgs());
        System.out.println("方法名：" + name + "，参数：" + args);
        try {
            Object result = joinPoint.proceed();
            System.out.println("方法返回值：" + result);
            return result;
        } catch (Throwable e) {
            throw new RuntimeException(e);
        }
    }
}
